package com.yfbao.horizon.docker.trx;

import org.jetbrains.annotations.NotNull;

import java.util.concurrent.ThreadFactory;

public class TrxTaskThreadFactory implements ThreadFactory {

    private String threadNamePrefix;

    public TrxTaskThreadFactory(String threadNamePrefix) {
        this.threadNamePrefix = threadNamePrefix;
    }

    @Override
    public Thread newThread(@NotNull Runnable r) {
        Thread thread = new Thread(r);
        thread.setName(threadNamePrefix + "-" + thread.getId());
        return thread;
    }
}
